<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>插件测试</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0">

		<script src="../../../dist/xsloader.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<h1>Hello World!</h1>
		<pre id="logDiv" style="padding: 10px;width: 100%;white-space: pre-wrap;word-wrap: break-word;*white-space: pre;*word-wrap: break-word;">
			
		</pre>
	</body>
	<script type="text/javascript">
		window.divLog = function(obj) {
			var div = document.getElementById("logDiv");
			var txt = (typeof obj == "string") && obj || xsJson2String(obj) || "";
			txt = txt.replace(/\\r\\n|\\n/g, "\n");
			txt = txt.replace(/\\t/g, "    ");

			div.innerText = div.innerText + "\n" + txt;
		};

		xsloader.onError = function(code, errinfo) {
			divLog(errinfo);
		}

		define("PluginA", {
			pluginMain: function(pluginArgs, onload, onerror, config, dep1, dep2) {
				if(pluginArgs == "true") {
					onload({
						code: 0,
						desc:"成功测试",
						rs: pluginArgs
					});
				} else {
					onerror({
						code: -1,
						desc:"错误测试",
						rs: pluginArgs
					});
				}
			}
		});

		xsloader({

		});
		
		require(["PluginA!true"], function(pa) {
			divLog(pa);
			divLog("---------------------------");
		}).error(function(err){
			console.error(err);
			divLog(err);
		});

		require(["PluginA!false"], function(pa) {
			divLog(pa);
		}).error(function(err){
			console.error(err);
			divLog(err);
		});

		
	</script>

</html>